Skip to main content

All Questions

Tagged with
0votes
2answers
246views

How to sort filename list (txt-file) by sub-strings of the filename/path with multiple levels. Special challenge: Two types of filename conventions

I'd like to sort the following list of filenames / pathes. L1_Data/level1/192027/LC08_L1TP_192027_20201126_20210316_01_T1 DONE L1_Data/level1/192028/LC08_L1TP_192028_20201126_20210316_01_T1 DONE ...
jaysigg's user avatar
2votes
3answers
842views

Extract a part of a filename

I have the filename TRNPRD.STD.BSRE.BREX.J.20190520.V02.PRET on a Linux machine, from which I need to extract only TRNPRD.STD.BSRE. I tried the following command: echo TRNPRD.STD.BSRE.BREX.J....
cautis anca's user avatar
2votes
1answer
4kviews

Extract filename from path string

I have a string like so /path/to/some/file.txt I want to extract only the file's name, without extension: file The problem is that this path is chosen randomly and I can't hardcode it into a ...
John Karmac's user avatar
1vote
0answers
68views

Is there a command specifically designed to manipulate file path strings, such as changing foo/bar/baz -> bar/baz?

I'm trying to modify the output of git diff --name-only from a subdirectory of a git project such that it only contains relative paths in the current directory. I know how to do this with sed/grep, ...
Garrett Motzner's user avatar
-4votes
2answers
1kviews

Finding specific string in XML file and storing in another file [closed]

Text in input file is like this <title> <band height="21" isSplitAllowed="true" > <staticText> <reportElement x="1" y="1" ...
Ankita Jain's user avatar
1vote
2answers
2kviews

Bash shell script to remove a guid within a filename

I'm trying to replace a guid without hyphens from some file names. I have the regex done, I think, however I can't seem to get either the escaping correct or the replacement commands to work with ...
Jules's user avatar
1vote
2answers
2kviews

How to find 4th and 5th character of files name?

$ ls abcmkde ghemkde vdecdde For example I only want to list out file name with only 4 and 5th character with only one iteration of single match (mk and cd in the example above). There is a bunch of ...
Jignesh Patel's user avatar
3votes
2answers
10kviews

Extracting number from filename

I have a filename following this model: 1.raw_bank_details_211.trg 2.raw_bank_details_222.trg I need to use the cut command in unix and cut the above string to obtain 211 and 222 from the strings ...
Rak kundra's user avatar
0votes
2answers
2kviews

How to grep the all filenames in folderA and (folderB inside folderA)?

I wanted to list down all the filenames within a folderA and another folderB inside folderA and saved it to a text file. The code I used is: ls -1 /home/CSV_XXX/* | grep ^'/home/CSV_XXX' >/home/...
Juliet.Y's user avatar
2votes
1answer
88views

Add string from file to filename

I need to rename files to include a string found in the first line. ex: [acoder@test]# head -1 FILE001.DAT XYZ123 Here's my best guess: for file in /some/dir/*.DAT do CODE=`head -1 "$...
a coder's user avatar
  • 3,343
1vote
2answers
714views

Get rid of 000A characters in file names

what is that "non-printable" char called so I can use the proper term to find or ask How do I remove that Char in order to rename my file, getting rid of it without ridding any other Chars of ...
uxserx-bw's user avatar
1vote
3answers
243views

Extract filename from another filename

I receive notification files for different files. I want to extract the filename from these notification files which I would use in another process. The first 4 strings of the notification file will ...
deon's user avatar
2votes
6answers
104views

How prepend appropriate amount of 0's to numbers contained in image names?

I've got a folder /User/me/Desktop/folder/images with files like key 1--name.jpg, key 10--name1.jpg, etc. The files are sorted incorrectly when fed to my site so I get an arrangement like key 84--name....
Yarlo19's user avatar
1vote
3answers
722views

Get directory name from file name

I want to make a directory name by extracting parts of a file name. Here are some examples: server.log.2016-03-20-14 → 20160320 server-2016-03-17-13-16-Restart.log → 20160317 I'm using HP-UX.
Chirag Dhaduk's user avatar
1vote
1answer
748views

Remove a part of a path from a variable content

In a Bash I have a variable: LOCAL_PATH="/this/is/a/path/" Then I have another variable, which content starts with LOCAL_PATH and it should be removed: LINE="/this/is/a/path/which/is/longer" The ...
witchi's user avatar

153050per page
close